<?
  session_start();
  require_once("core.php");
  
  get_all_variables();  
  $db = dbconnect();
  
   if ($submitted==1) { 
  /* User Input Analyse*/
  
  if (($nickname=='')||($password=='')){ header('Location: ../chat/msg.php?exitcode=2'); exit;} else
  
  if (strlen($nickname)<3){ header('Location: ../chat/msg.php?exitcode=3'); exit;} else
  
  if (strlen($password)<6){ header('Location: ../chat/msg.php?exitcode=5'); exit;};
  
  /* End of User Input Analyse */ 
  
  $nickname = addslashes($nickname);
  $password = addslashes($password);
  
  /* Database Check */
  $q = "
  SELECT *
  FROM `users`
  WHERE (  Nickname = '{$nickname}'  )  AND (  PASSWORD = '{$password}'  )";
  $r = mysql_query($q, $db) or die(header('Location: ../chat/msg.php?exitcode=8'));
  
  $n = mysql_num_rows($r);
  $w = mysql_fetch_array($r);
  
  if ($n==0) { header('Location: ../chat/msg.php?exitcode=9'); exit;} else
  {
    $_SESSION['U'] = $w['ID'];
    $_SESSION['Nick'] = $nickname;
	 header('Location: ../chat/beta.php'); exit;
  }
  
  /* End of Database Check */
  }
  
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>openOli Beta | Login</title>
<link href="css/yahoo_reset.css" rel="stylesheet" type="text/css" />
<script type="text/javascript">
 function turnOnBg (elm) {
   elm.style.backgroundColor = "#FFFFFF";
 }
 
  function turnOffBg (elm) {
   elm.style.backgroundColor = "#FFFF99";
 }
</script>
<style type="text/css">
<!--
#header {
   background-image:url(img/rm_logo_bg.png);
   width: 100%;
   height: 128px;
   margin-top: 15%;
  }
  
body {
	background-color: #EFEFEF;
}

#h_menu {
 color:#FFFFFF;
 font: 28px Arial, Helvetica, sans-serif;
 margin-left: 20px;
 margin-top: 8px;
 float: left;
}

.hm_smallfont {
 font-size: 18px;
}

.hm_input {
 color: #000000;
 font: 18px Arial, Helvetica, sans-serif;
 background-color: #FFFF99;
 border: 1px solid #FF0000;
 margin: 4px;
 padding: 2px;
 vertical-align: middle;
}

#hm_go{
  width: 45px; 
  height: 72px;
  background-image: url(img/gorrow.png);
  background-position: top;
  cursor: pointer;
}
a:link {
	color: #FFFFFF;
	text-decoration: none;
}
a:visited {
	text-decoration: none;
	color: #FFFFFF;
}
a:hover {
	text-decoration: underline;
	color: #FFFFFF;
}
a:active {
	text-decoration: none;
	color: #FFFFFF;
}

-->
</style>
</head>

<body>
 <div id="header">
   <img src="img/rm_logo.png" alt="RM_LOGO" width="128" height="128" style="margin-left: 3px; float:left;" />
   <div id="h_menu">
     Log in <span style="font-size: 16px; ">or <a href="register.php">Register</a> if you have no account.</span><br />
     <div>
     <form action="login.php" method="post" enctype="multipart/form-data" name="log_form">
	   <input name="submitted" type="hidden" value="1" />
	   <input type="submit" style="display:none;" />
      <div style="float:left;">
       <label for="nickname" class="hm_smallfont">Nickname: </label><input name="nickname" type="text" id="nickname" class="hm_input" onfocus="turnOnBg(this)" onblur="turnOffBg(this)" /><br />
       <label for="password" class="hm_smallfont">Password: </label><input name="password" type="password" id="password" class="hm_input" onfocus="turnOnBg(this)" onblur="turnOffBg(this)" />
      </div>
      <div style="float:left;">
        <div id="hm_go"></div> 
      </div>
     </form>
     </div>
     
   </div>
 </div>
 
 <script type="text/javascript">
 document.getElementById('hm_go').onmouseover = function() {
   this.style.backgroundPosition = "bottom";
  }
 
  document.getElementById('hm_go').onmouseout = function() {
   this.style.backgroundPosition = "top";
  } 
 
  document.getElementById('hm_go').onclick = function() {
   document.log_form.submit();
  } 
 </script>
</body>
</html>
